/*
 *  Copyright 2012 SerGenis. All rights reserved.
 */
package com.sergenis.swing;

import java.awt.Image;

/**
 *
 * @author SerGenis
 */
public class JPanelImage
    extends javax.swing.JPanel {

    public JPanelImage() {
	this(null);
    }

    public JPanelImage(Image image) {
	setOpaque(false);
	this.image = image;
    }
    private Image image;

    public Image getImage() {
	return image;
    }

    public void setImage(Image image) {
	Image old = this.image;
	this.image = image;
	firePropertyChange("image", old, image);
	repaint();
    }

    @Override
    public final void paint(java.awt.Graphics g) {
	if (image != null) g.drawImage(image, 0, 0, this);
	super.paint(g);
    }
}
